package com.graphics;

import java.io.File;
import java.util.ArrayList;
import mapgenerator.Main;

/**
 * Created on Feb 20, 2009, 22:14:41 PM
 *
 * @author Sajarwo Anggai
 */
public class ImageContainer {

    private ArrayList<String> listImages;
    private Main comp;

    public ImageContainer(Main comp) {
        this.comp = comp;
        listImages = new ArrayList<String>();
    }

    public void addImage(String imName) {
        listImages.add(imName);
    }

    /**
     *
     * @param src - src.png
     * @param dst - dst.png
     */
    public void renameImage(String srcName, String dstName) {
        //File f=new File(src);
        //System.out.println(listImage.size());
        System.out.println("srcName = "+srcName);
        System.out.println("srcName = "+dstName);
        System.out.println(listImages.indexOf(srcName));
        listImages.set(listImages.indexOf(srcName), dstName);
    }

    public ArrayList getImages() {
        return listImages;
    }

    public boolean removeImage(String imName) {
        File f = new File(comp.project.getImageDir()+File.separator+imName);
        System.out.println(f);
        if (f.delete()) {
            System.out.println("File has beent deleted : yes");
            return this.listImages.remove(imName);
        }
        return false;
    }

    public boolean removeImage(int index) {
        return removeImage(index);
    }

    public void clearAll() {
        this.listImages.clear();
    }
}
